package com.amap.search.controller;

import cn.hutool.core.util.NumberUtil;
import com.amap.search.entity.db2022.WeatherRecord;
import com.amap.search.entity.vo.AmapPoiRequest;
import com.amap.search.entity.vo.AmapPoiRequest2;
import com.amap.search.entity.vo.AmapPoiResponse;
import com.amap.search.entity.vo.AmapPoiResponse2;
import com.amap.search.entity.vo.AmapWeatherRequest;
import com.amap.search.entity.vo.AmapWeatherResponse;
import com.amap.search.mapper.db2022.WeatherRecordMapper;
import com.amap.search.service.AmapHttpService;
import com.amap.search.util.RestHttpUtil;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.elasticsearch.index.engine.Engine;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/test")
public class TestController {
    @Resource
    private WeatherRecordMapper weatherRecordMapper;

    @Resource
    private AmapHttpService amapHttpService;

    @GetMapping("/getString")
    public String testString() {
        return "test success!";
    }

    @GetMapping("/getData")
    public List<WeatherRecord> getDataList() {
        return weatherRecordMapper.selectList(new EntityWrapper<WeatherRecord>().le("id", 20));
    }

    @GetMapping("/getWeather")
    public AmapWeatherResponse getWeather(String city) {
        AmapWeatherRequest request = new AmapWeatherRequest();
        request.setCity(city);
        return amapHttpService.getWeatherInfo(request);
    }

    @PostMapping("/getPoi")
    public AmapPoiResponse getPoi(@RequestBody AmapPoiRequest request) {
        return amapHttpService.getPoiInfo(request);
    }


    @PostMapping("/getPoi2")
    public AmapPoiResponse2 getPoi2(@RequestBody AmapPoiRequest2 request) {
        return amapHttpService.getPoiInfo(request);
    }
}
